package com.qcby.byc.demo0422.controller;

import com.qcby.byc.demo0422.aop.ViewRecords;
import com.qcby.byc.demo0422.entity.DateThread;
import com.qcby.byc.demo0422.entity.Demo0528;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * @className: Demo0528Controller
 * @description:
 * @author: lxt
 * @create: 2021-05-28 15:19
 **/
@Slf4j
@RequestMapping("demo0528")
@RestController
public class Demo0528Controller {
    private final static String strDateFormat = "yyyy-MM-dd";
    public static void main(String[] args) throws InterruptedException {
        //  时间格式化
        // 要求输出  2020-20-02 10:10:10
        SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);
        for (int i = 1; i <= 10; i++) {
            DateThread dateThread = new DateThread(sdf,i);
            dateThread.start();
        }

    }
    public static String format(SimpleDateFormat sdf,Date date){
        return sdf.format(date);
    }
    public static String format(LocalDate localDate){
        return localDate.format(DateTimeFormatter.ofPattern(strDateFormat));
    }


//    @ViewRecords
//    @RequestMapping
//    public Demo0528 index(@RequestBody Demo0528 demo0528){
//        log.info("demo0528:{}",demo0528);
//        return demo0528;
//    }


    /**
     *              =>   @RequestBody
     * @param demo0528
     * @return
     */
    @RequestMapping
    public Demo0528 index1(Demo0528 demo0528){
        log.info("demo0528:{}",demo0528);
        return demo0528;
    }





}
